<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="Css/loginCss.css">
    <script src="jQuery.js"></script>
    <script>
        // 进入页面 和后端通信，判断当前的PHPSESSID 是否登录过
        $.ajax({
            url: "/login/validateLogin.php",
            data: {},
            type: "post",
            dataType: "json",
            async: false,
            success: function (data) {
                if (data.code === 200) {
                    location.href = "index.html";
                }

            }
        });
    </script>
</head>
<body>
<div class="container">
    <div class="login">
        <div class="head">
            <span>欢迎登录学生选课系统</span>
        </div>
        <div class="user">
          <span>*用户名</span><input type="text" placeholder="请输入用户名" id="username">
        </div>
        <div class="user-One">
            <span>*密码</span><input type="password" placeholder="请输入用户名" id="password">
        </div>
        <div class="rom">
            <input type="checkbox" checked id="auto"><span>下次自动登录</span>
            <a href="#">注册</a>
        </div>
        <div class="man"><p><span>登</span><span>录</span></p></div>
    </div>
</div>
<script>
    $(function () {
    $(".man").click(function () {
        //自动登录
        //进入ajax
        $.ajax({
            url:"/login/loginX.php",
            type:'POST',
            data:{
                name:$("#username").val(),
                password:$("#password").val(),
                auto:$("#auto").prop('checked')? 1 : 0//如果true为选中 则为1 文档要求
            },
            async: true,
            dataType: "json",
            success:function (data) {
                if (data.code===200){
                    location.href = "index.html";
                }
            },
        })
    })
    })
</script>
</body>
</html>